package java6681.lesson01;

import java.util.Arrays;

public class Shopping6681 {
    public static void main(String[] args) {
//        创建超市、货物对象，指定其名称、可以销售的商品清单
//        货物
        Product6681 one = new Product6681("摄像头");
        Product6681 two = new Product6681("电视机");
        Product6681 three = new Product6681("键盘");
        Product6681 four = new Product6681("笔记本");
        Product6681[] pList = new Product6681[]{one, two, three, four, new Product6681("可乐")};

//        超市
        Market6681 market = new Market6681("永辉", pList);

//        创建购物者对象，指定名称
        Person6681 person = new Person6681("Junichiro");

//          创建需要购买的商品清单
        Product6681[] buyList = new Product6681[]{new Product6681("键盘"), new Product6681("笔记本"), new Product6681("牛奶")};

        /*调用购物者的shopping方法购买商品*/
        String strProduct = person.shopping(market, buyList);

        /*输出结果*/
        System.out.println(person + "的购物清单" + Arrays.toString(buyList));
        if (strProduct.isEmpty()) {
            System.out.println(person + "白跑一趟，在" + market + "什么都没有买到");
        } else {
            System.out.println(person + "在" + market + "买到了:" + strProduct);
        }

        //        if (sp != null){
//            System.out.println(person.getName() + "的购物清单:" + Arrays.toString(sp));
//        }else{
//            System.out.println(person.getName() + "没有要买的" );
//        }
//
////         买多个商品
//        String shopping = person.shopping(market, sp);
//        if (shopping != null) {
//            System.out.println(person.getName() + "在" + market.getName() + "超市买到了:" + shopping);
//        } else {
//            System.out.println(person.getName() + "在" + market.getName() + "超市什么都没有买到");
//        }


////         买单个商品
//        Product6681 result = person.shopping(market,"键盘" );
//
//        if (result != null){
//            System.out.println(person.getName() + "在" + market.getName() + "超市买到了:" + result);
//        }else{
//            System.out.println(person.getName() + "在" + market.getName() + "超市什么都没有买到");
//        }

    }
}
